package com.tengju.bff.interfaces.shared;

import com.fasterxml.jackson.annotation.JsonValue;
import com.tengju.data.domain.shared.JsonUtil;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author: 李大仙
 * @Date: 2021/4/9 2:40 下午
 */
public class NameSensitiveVO {

    public NameSensitiveVO(String name) {
        this.name = name;
    }

    private String name;

    @Override
    @JsonValue
    public String toString() {
        if (StringUtils.isBlank(name)) {
            return "";
        }
        String fullName = name;
        String name = StringUtils.left(fullName, 1);
        return StringUtils.rightPad(name, StringUtils.length(fullName), "*");
    }

    public static void main(String[] args) {
        System.out.println(JsonUtil.toJSONString(new NameSensitiveVO("张三")));
    }
}
